package com.tarena.day030;
/** 类型转换 */
public class CastDemo {
  public static void main(String[] args) {
    byte b = -1;
    System.out.println(Integer.toBinaryString(b)); 
    System.out.println(Integer.toBinaryString((int)b)); 
    //不超过byte范围的"int字面量"可以对byte类型赋值
    b = -128;// 11111111 11111111 11111111 10000000
    b = 0xffffff80;
    //b = 0x80;// 编译错误, 超过范围, 128
    b = (byte)0x80;
    int a = 0xffffff80;
    //b = a;//编译错误, int变量不能直接赋值给byte
    b = (byte)a;
    a = 0xfff0ff80;
    System.out.println(a);
    b = (byte)a;
    System.out.println(b); 
    a = 0x7ff0ff80;
    b = (byte)a;
    System.out.println(b); 
    b = (byte)0x7ff0ff80;
    System.out.println(b); 
  }
}






